/**
 * 
 */
package teehee.Manager;

import java.text.DecimalFormat;
import java.util.ArrayList;

import android.content.Context;

import teehee.DB.DBHealth;

/**
 * @author 
 *
 */
public class HealthManager {
	
	public static int getSize()
	{
		return DBHealth.getSize();
	}
	
	public static String generateHistory(String height, String weight)
	{
                
     	    Double weightval = Double.parseDouble(weight);
  	        Double heightval = Double.parseDouble(height);
  	        Double bmival =  roundTwoDecimals(( weightval/ ( heightval * heightval ) ) * 703);
  	        return bmival+"";
	}
	
	public static double roundTwoDecimals(double d) {
        DecimalFormat twoDForm = new DecimalFormat("#.##");
        return Double.valueOf(twoDForm.format(d));
    }
	
	public static String[] getData(int i)
	{
		ArrayList<DBHealth> list = DBHealth.getHealthHistory();
		String[] arg = new String[2];
		DBHealth entry = list.get(i);
		arg[0] = entry.getWeight();
		arg[1] = entry.getDate();
		return arg;
	}
	
	public static String getHeight(Context ctx)
	{
		return DBHealth.getHeight(ctx);
	}
	
	public static void updateHeight(String height, Context ctx)
	{
		DBHealth.updateHeight(height, ctx);
	}
}
